package com.ihai.spring.boot.sample.aop.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * DESC
 *
 * @author 张驰
 * @date 2018/7/11
 */
@Aspect
@Component
public class LogAspect {

    @Pointcut("execution(* com.ihai.spring.boot.sample.aop.service.*.*(..))")
    public void declareJointPointExpression(){}

    @Before("declareJointPointExpression()")
    public void log(JoinPoint joinPoint){
        String methodName = joinPoint.getSignature().getName();
        Object[] args = joinPoint.getArgs();
        System.out.println("before method " + methodName + " begin with:" + Arrays.asList(args));
    }
}
